package com.atguigu.eduservice.controller;


import com.atguigu.commonutils.result.R;
import com.atguigu.eduservice.entity.subject.OneSubject;
import com.atguigu.eduservice.service.EduSubjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * <p>
 * 课程科目 前端控制器
 * </p>
 *
 * @author ran
 * @since 2022-02-18
 */
@RestController
@RequestMapping("/eduservice/subject")
@CrossOrigin//跨域
public class EduSubjectController {

    @Autowired
  private EduSubjectService eduSubjectService;

    @PostMapping("addSubject")//获取上传过来文件，把文件内容读取出来
    public R addSubject(MultipartFile file){
        //为啥要把eduSubjectService传到impl
        eduSubjectService.saveSubject(file,eduSubjectService);
        return R.ok();
    }
    @GetMapping("getAllSubject")
    public R getAllSubject(){
      List<OneSubject> list = eduSubjectService.getAllOneTwoSubject();
        return R.ok().data("list",list);
    }


}

